import request from '#/utils/requestAbort.js';
import { serverUrl } from '../../../../config/urlConfig';

// 交易中心字典项
export async function getMarket() {
  return request('/market-disclosure/transactionDictionaryCalendarV2/getMarket', {
    method: 'GET',
  });
}

// 交易单元
export async function getMaxElectricityGenerationRole() {
  return request(
    '/market-disclosure/transactionDictionaryCalendarV2/getMaxElectricityGenerationRole',
    {
      method: 'GET',
    },
  );
}
// 创建人
export async function pendingCreatorH(dateList?: any[], activeKey?: string) {
  // 接口修改为跟日期和tab有关
  return request('/market-disclosure/transactionDictionaryCalendarV2/pendingCreator', {
    method: 'POST',
    data: {
      dateList,
      queryType: activeKey,
    },
  });
}

export async function batchRemovePendingH(params: any) {
  return request('/market-disclosure/transactionCalendarV2/batchRemovePending', {
    method: 'POST',
    data: params,
  });
}

export async function batchSavePendingRelaH(params: any) {
  return request('/market-disclosure/transactionCalendarV2/batchSavePendingRela', {
    method: 'POST',
    data: params,
  });
}

// 设置/批量提醒设置
export async function batchSetRemindH(params: any) {
  return request('/market-disclosure/transactionCalendarV2/batchSetRemind', {
    method: 'POST',
    data: params,
  });
}

// 公告序列详情
export async function noticeSequenceDetailH(params: any) {
  return request('/market-disclosure/transactionCalendarV2/detail', {
    method: 'POST',
    data: params,
  });
}

// 编辑自定义序列 (包含了新增，编辑，删除三种操作接口)
export async function editAttachmentCustomH(params: any) {
  return request('/market-disclosure/transactionCalendarV2/editAttachmentCustom', {
    method: 'POST',
    data: params,
  });
}

// 编辑自定义公告 (包含了新增，编辑，删除三种操作接口)
export async function editNoticeCustomH(params: any) {
  return request('/market-disclosure/transactionCalendarV2/editNoticeCustom', {
    method: 'POST',
    data: params,
  });
}

// 编辑待办
export async function editPendingH(params: any) {
  return request('/market-disclosure/transactionCalendarV2/editPending', {
    method: 'POST',
    data: params,
  });
}

// 编辑用户组
export async function editUserGroupH(params: any) {
  return request('/market-disclosure/transactionCalendarV2/editUserGroup', {
    method: 'POST',
    data: params,
  });
}

// 月维度-清单
export async function getMonthViewH(params: any) {
  return request('/market-disclosure/transactionCalendarV2/getMonthView', {
    method: 'POST',
    data: params,
  });
}

// 列表数据查询
export async function getTodoNoticeSequenceListH(params: any) {
  return request('/market-disclosure/transactionCalendarV2/list', {
    method: 'POST',
    data: params,
  });
}

// 待办详情
export async function queryPendingDetailH(params: any) {
  return request('/market-disclosure/transactionCalendarV2/queryPendingDetail', {
    method: 'POST',
    data: params,
  });
}

// 关联公告/序列
export async function relationPending(params: any) {
  return request('/market-disclosure/transactionCalendarV2/relationPending', {
    method: 'POST',
    data: params,
  });
}

// 关联公告/序列
export async function relationPendingH(params: any) {
  return request('/market-disclosure/transactionCalendarV2/relationPending', {
    method: 'POST',
    data: params,
  });
}

export async function savePendingH(params: any) {
  return request('/market-disclosure/transactionCalendarV2/savePending', {
    method: 'POST',
    data: params,
  });
}

// 上传文件
export async function upLoadFiles(params: any) {
  return request(`${serverUrl}/annex/annex/upLoadFiles`, {
    method: 'POST',
    requestType: 'form',
    data: params,
  });
}

export async function downLoadFile(fileId: string) {
  return request(`/annex/annex/downLoadFile/${fileId}`, {
    method: 'GET',
  });
}

export async function preview(params: any) {
  return request(`/annex/annex/selectFileByIdList`, {
    method: 'POST',
    data: { ...params },
  });
}

// 设置提醒弹窗获取组织和人员
export async function getTianJiUserServerH() {
  return request('/market-disclosure/transactionDictionaryCalendarV2/getTianJiUser', {
    method: 'GET',
  });
}

// 导出文件接口-用于预览pdf的时候调用
export async function downLoadFilePDF(fileId: string) {
  return request(`${serverUrl}/annex/annex/downLoadFile/${fileId}`, {
    method: 'GET',
    responseType: 'blob',
  });
}
